<template>
  <div>

    <Head v-if="isShow"></Head>
    <router-view></router-view>
    <Foot v-if="isShow"></Foot>
  </div>
</template>

<script setup>
import Head from '@/components/Head.vue'
import Foot from '@/components/Foot.vue'
import { useRouter } from 'vue-router';
import { ref } from 'vue'

const isShow = ref(true)
const router = useRouter()
// 某些页面是不需要头的
const whiteList = ['/login', 'register']
router.beforeEach((to, from, next) => {    //页面跳转之前触发
  if (whiteList.includes(to.path)) {  // 如果是白名单中的页面
    isShow.value = false
    next()
  } else {
    isShow.value = true
    next()  // 跳转到其他页面
  }
})

</script>

<style lang="less" scoped></style>